<?php

namespace App\View\Components;

use App\Facade\Code;
use Illuminate\Support\Facades\Request;
use Illuminate\View\Component;

class StatusBar extends Component
{
    public $value;
    public $allText;
    public $kv;
    public $name;
    public $url;
    public $dynamicWhere;
    public $searchFormId;

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($code, $url, $searchFormId='formSearch', $name = 'status', $dynamicWhere = '',$value = '', $allText = '所有')
    {

        $this->name = $name;
        $this->url = $url;
        $this->searchFormId = $searchFormId;
        $this->dynamicWhere = $dynamicWhere;
        $this->allText = $allText;
        if (empty($value)) {
            $value = Request::input($name, '');
        }
        $this->value = $value;
        $this->kv = Code::get($code);
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return view('components.status-bar');
    }
}
